home *** CD-ROM | disk | FTP | other *** search
- Path: osf1.gmu.edu!adomingu
- From: adomingu@osf1.gmu.edu (Aires C Domingues)
- Newsgroups: comp.lang.c
- Subject: "Double to 2 Unsigned Longs"
- Date: 17 Feb 1996 17:36:21 GMT
- Organization: George Mason University, Fairfax, Virginia, USA
- Message-ID: <4g53ml$haj@portal.gmu.edu>
- NNTP-Posting-Host: osf1.gmu.edu
- Mime-Version: 1.0
- Content-Type: text/plain; charset=US-ASCII
- Content-Transfer-Encoding: 7bit
- X-Newsreader: TIN [version 1.2 PL2]
-
- How to go about storing a double (used to store very large integers) to
- a user defined 64 bit integer (structure with two unsigned long fields)?
-
- The user defined 64 bit integer looks something like this:
-
- typedef struct {
- unsigned long high;
- unsigned long low;
- } UINT64;
-
- Where "high" is used to save the high order bits for the really big integer,
- and "low" is used for the low order bits.
-
- One idea is to take the double and divide it by 2**32. The we can save the
- resulting integral part of the division in "high", and the remainder in the
- "low". This will off-course lead to rounding errors. Any other ideas?
-